<!DOCTYPE html>
<html>
<head>
<!--    用的page-form.html-->
    <meta charset="utf-8">
    <title>layui</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="lib/layui-v2.6.3/css/layui.css" media="all">
    <link rel="stylesheet" href="css/public.css" media="all">
</head>
<body>
<div class="layuimini-container">
    <div class="layuimini-main">
        <form class="layui-form" action="">
<!--            <div class="layui-form-item">-->
<!--                <label class="layui-form-label">房间状态：</label>-->
<!--                <div class="layui-input-block">-->
<!--                    <input name="roomstatus" lay-verify="title" class="layui-input">-->
<!--                </div>-->
<!--            </div>-->
            <div class="layui-form-item">
                <label class="layui-form-label required">房间状态：</label>
                <div class="layui-input-block">
                    <input type="radio" name="roomstatus" value="可预订" title="可预订" checked="">
                    <input type="radio" name="roomstatus" value="可入住" title="可入住">
                    <input type="radio" name="roomstatus" value="可预订可入住" title="可预订可入住">
                    <input type="radio" name="roomstatus" value="房型已满" title="房型已满">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">可用房间数：</label>
                <div class="layui-input-block">
                    <input name="ableroomnumber" lay-verify="title" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">已预定房间数：</label>
                <div class="layui-input-block">
                    <input name="reserveroomnumber" lay-verify="title" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">已入住数：</label>
                <div class="layui-input-block">
                    <input name="occupantsnumber" lay-verify="title" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">房间类型id：</label>
                <div class="layui-input-block">
                    <input name="roomtypeid" lay-verify="title" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-input-block">
                    <button class="layui-btn" lay-submit lay-filter="demo1">添加房间类型信息</button>
                    <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                </div>
            </div>
        </form>
    </div>
</div>

<script src="lib/layui-v2.6.3/layui.js" charset="utf-8"></script>
<script src="js/jquery-3.6.0.min.js" charset="utf-8"></script>
<!-- 注意：如果你直接复制所有代码到本地，上述js路径需要改成你本地的 -->
<script>
    layui.use(['form'], function () {
        var form = layui.form
            , layer = layui.layer;

        //监听提交
        form.on('submit(demo1)', function (data) {
            console.log(data.field);
            //ajax 调用接口
            $.post("/api/roomstatus/save.do",data.field,function(res){
                if(res.code==200){
                    //新增成功
                    layer.msg('新增成功！');
                }else{
                    //新增失败
                    layer.msg('新增失败！');
                }
            });
            return false;
        });
    });
</script>
</body>
</html>